# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <cmath>

using namespace std;

#include "tri.hh"
#include "utils.hh"

int main ( )
{
  int seed = 12345678;
  timestamp ( );

  cout << "\n  Test the Triangular element basis functions.\n" << seed;

  double* txy = r8vec_uniform_01_new ( 3, &seed );

  double t[9] = { txy[0], 0.0, 0.0,
                  txy[0], txy[1], 0.0,
                  txy[2], txy[1], 0.0 } ;

  Tri3 tri3(t) ;
  tri3.test() ;

  double u[12] = { 
    2.0, 0.0, 0.0,
    4.0, 3.0, 0.0,
    0.0, 4.0, 0.0,
    0.0, 0.0, 0.0 };
//
//  The node associated with the fourth basis function is the centroid.
//
  u[0+3*3] = ( u[0+0*3] + u[0+1*3] + u[0+2*3] ) / 3.0;
  u[1+3*3] = ( u[1+0*3] + u[1+1*3] + u[1+2*3] ) / 3.0;

  Tri4 tri4(u) ;
  tri4.test() ;

  double v[18] = { 
    2.0, 0.0, 0.0,
    10.0, 4.0, 0.0,
    4.0, 3.0, 0.0,
    6.0, 2.0, 0.0,
    7.0, 3.5, 0.0,
    3.0, 1.5, 0.0 };

  Tri6 tri6(v) ;
  tri6.test() ;

//
//  Terminate.
//
  cout << "\n  Normal end of execution.\n\n";

  timestamp ( );

  delete txy;
  //delete t;

  return 0;
}
